package ntu.sna;

public class test2 {
	public static void main(String[] args) {
		double[] tmp = new double[100];
		for(int i=0; i<100 ; i++){
			tmp[i]=0;
		}
		for(int i=0; i<100 ; i++){
			tmp[i]=skew((double)i,90,30,-4)/20;
			//System.out.println(i+" : "+tmp[i]);
		}
		for(int i=0; i<100 ; i++){

			System.out.println(tmp[i]);
		}
	}
	
	
	public static double pdf(double x ){
		return 1/Math.sqrt(2*Math.PI) * Math.exp(Math.pow(x,2)*(-1)/2);
	}
    
	public static double cdf(double x ){
		return (1 + erf( x/Math.sqrt(2) ))/2; 
	}
	
    public static double erf(double z) {
        double t = 1.0 / (1.0 + 0.5 * Math.abs(z));

        // use Horner's method
        double ans = 1 - t * Math.exp( -z*z   -   1.26551223 +
                                            t * ( 1.00002368 +
                                            t * ( 0.37409196 + 
                                            t * ( 0.09678418 + 
                                            t * (-0.18628806 + 
                                            t * ( 0.27886807 + 
                                            t * (-1.13520398 + 
                                            t * ( 1.48851587 + 
                                            t * (-0.82215223 + 
                                            t * ( 0.17087277))))))))));
        if (z >= 0) return  ans;
        else        return -ans;
    }
    
	public static double skew(double x ,double e , double w , double a){
		double t = (x-e) / w;
		return 2 * pdf(t) * cdf(a*t);
	}

}
